(function(global, document, _fns, $, console) {
    'use strict';

    /*

        @name 自动嵌套命名空间

        @desc

        @author

        @access protected

        @function _extend

        @param {Object} ns 顶级命名空间

        @param {string} [nsString = tlns.ns1.ns2.ns3] 基于顶级命名空间要嵌套的命名空间

        @returns {Object} 返回嵌套好的对象。

        @example
            // " tlns.sample = $.noop; " === " tlns.ns1.ns2.ns3.sample = $.noop; "
            var tlns = _extend(tlns, "tlns.ns1.ns2.ns3");

        @todo 将这个函数放入公共函数库中。
     */
    var _extend, exc;
    _extend = function(ns, nsString) {
        var i, parent, parts, pl;
        parts = nsString.split(".");
        parent = ns;
        pl = parts.length;
        i = 0;
        while (i < pl) {
            if (typeof parent[parts[i]] === "undefined") {
                parent[parts[i]] = {};
            }
            parent = parent[parts[i]];
            i++;
        }
        return parent;
    };
    exc = _extend(_fns, "_fns.excute");

    /*
        @desc

        @author

        @access protected

        @function exc._fast_click
     */
    exc.sidebar = function() {
        //global.lsBar();
    };

    exc.did = function() {
        var btnOrder = $('.sec-order-details').find('.btn-keep-paying');
        var orderType = $('.sec-order-details').find('.btn-keep-paying').attr('orderType');
        var url_start;
        if (orderType && orderType == 'promotion') {
            url_start = "/member/proOrderStatus/";
        } else {
            url_start = "/member/orderStatus/";
        }

        //检查定单是否支付
        var checkOrderPayStatus = function(orderId, payUrl) {
            $.get(url_start + orderId + ".htm", function(data) {
                if (data === 'true') {
                    window.location.assign(payUrl);
                } else {
                    ECar.easyDialog.open({
                        container: {
                            header: '提示',
                            content: '<div style="text-align:center">无效定单!</div>'
                        }
                    });
                }
            });
            return true;
        };

        btnOrder.on('click', function(e) {
            var that;
            that = $(this);
            checkOrderPayStatus(that.data('orderid'), that.data('payurl'));
        });
    };

    /*
        @name 初始化

        @desc 所有在 " _fns.excute " 命名空间下定义的函数将被自动运行。

        @author

        @access protected

        @function _fns.init

        @param {Object} opts 存放定义好的可任意修改（配置）的行为选项。
     */
    _fns.init = function(opts) {
        var _it;
        for (_it in exc) {
            if (typeof exc[_it] === "function") {
                exc[_it]();
            }
        }
    };
    $(_fns.init);
    /*添加 2016-11-18号*/
    (function() {
        var checkMore = $(".js_check_more");
        checkMore.each(function(i, ele) {
                   // console.log(i, $(ele));
                   $(this).on("click",function(){
                        var _this = $(this),
                        thisSibiling = _this.siblings('.js_check-detail'),
                        arrowFlag = _this.hasClass('arrow-up');

                        if (!arrowFlag) { // $(".js_check-detail")有.arrow-up类名，则$(".js_check-detail")展开

                            if (thisSibiling.hasClass('pay-cont')) {
                                thisSibiling.css("height", "auto");;
                                _this.addClass('arrow-up');
                            } else {  // 判断物流跟踪 详情 盒子
                                thisSibiling.css("height", "auto");
                                _this.addClass('arrow-up');
                            }

                        } else {

                            if (thisSibiling.hasClass('pay-cont')) {
                                thisSibiling.css("height", "28px");
                                _this.removeClass('arrow-up');
                            } else {
                                thisSibiling.css("height", "112px");
                                _this.removeClass('arrow-up');
                            }

                        }
               })

        });
    })();

})(window, document, {}, jQuery, (typeof console !== 'undefined' ? console : void 0));




function doSubmit(orderId){
	
	var storeId = $(':radio[name=dealer-id]:checked').val();
	$.ajax({
        type: "POST",
        url: "/member/updateStoreId.htm",
        data: {"orderId":orderId,"storeId":storeId},
        dataType: "json",
        success: function(data){
        	if(data.errorCode=='0'){
        		window.location.reload();
        	}else{
        		alert('操作失败,请稍后再试');
        	}
        },
        error:function(){
        	alert('操作失败,请稍后再试');
        }
    });
	
}



